import numpy as np

# The coal mining disaster dataset originates from:
#       http://people.reed.edu/~jones/141/Coal.html

_data = [
    [1851, 4],
    [1852, 5],
    [1853, 4],
    [1854, 1],
    [1855, 0],
    [1856, 4],
    [1857, 3],
    [1858, 4],
    [1859, 0],
    [1860, 6],
    [1861, 3],
    [1862, 3],
    [1863, 4],
    [1864, 0],
    [1865, 2],
    [1866, 6],
    [1867, 3],
    [1868, 3],
    [1869, 5],
    [1870, 4],
    [1871, 5],
    [1872, 3],
    [1873, 1],
    [1874, 4],
    [1875, 4],
    [1876, 1],
    [1877, 5],
    [1878, 5],
    [1879, 3],
    [1880, 4],
    [1881, 2],
    [1882, 5],
    [1883, 2],
    [1884, 2],
    [1885, 3],
    [1886, 4],
    [1887, 2],
    [1888, 1],
    [1889, 3],
    [1890, 2],
    [1891, 2],
    [1892, 1],
    [1893, 1],
    [1894, 1],
    [1895, 1],
    [1896, 3],
    [1897, 0],
    [1898, 0],
    [1899, 1],
    [1900, 0],
    [1901, 1],
    [1902, 1],
    [1903, 0],
    [1904, 0],
    [1905, 3],
    [1906, 1],
    [1907, 0],
    [1908, 3],
    [1909, 2],
    [1910, 2],
    [1911, 0],
    [1912, 1],
    [1913, 1],
    [1914, 1],
    [1915, 0],
    [1916, 1],
    [1917, 0],
    [1918, 1],
    [1919, 0],
    [1920, 0],
    [1921, 0],
    [1922, 2],
    [1923, 1],
    [1924, 0],
    [1925, 0],
    [1926, 0],
    [1927, 1],
    [1928, 1],
    [1929, 0],
    [1930, 2],
    [1931, 3],
    [1932, 3],
    [1933, 1],
    [1934, 1],
    [1935, 2],
    [1936, 1],
    [1937, 1],
    [1938, 1],
    [1939, 1],
    [1940, 2],
    [1941, 4],
    [1942, 2],
    [1943, 0],
    [1944, 0],
    [1945, 0],
    [1946, 1],
    [1947, 4],
    [1948, 0],
    [1949, 0],
    [1950, 0],
    [1951, 1],
    [1952, 0],
    [1953, 0],
    [1954, 0],
    [1955, 0],
    [1956, 0],
    [1957, 1],
    [1958, 0],
    [1959, 0],
    [1960, 1],
    [1961, 0],
    [1962, 1],
]

def get_events_spiked():
    events = []
    for year, count in _data:
        for _ in range(count):
            events.append(year)
    return events

def get_events_distributed(uniform=False, rng=np.random.RandomState()):
    events = []
    for year, count in _data:
        if uniform:
            yearfractions = np.linspace(0, 1, count + 1)[:-1]
        else:
            yearfractions = rng.uniform(size=count)
            yearfractions.sort()
        events.append(year + yearfractions)
    return np.concatenate(events)

domain = [1851, 1962]
